/*
 * HMSBJJButton.java
 *
 * Created on January 5, 2006, 11:25 AM
 *
 * To change this template, choose Tools | Options and locate the template under
 * the Source Creation and Management node. Right-click the template and choose
 * Open. You can then make changes to the template in the Source Editor.
 */
package com.bff.bjj.ui.component;

import java.awt.BasicStroke;
import java.awt.Graphics;

import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.geom.RoundRectangle2D;
import javax.swing.Action;
import javax.swing.JButton;

public class BJJButton extends JButton implements MouseListener {

    boolean mouseIn = false;

    public BJJButton() {
        super();
    }

    public BJJButton(Action a) {
        super(a);
    }

    public BJJButton(String s) {
        super(s);
        addMouseListener(this);
        setContentAreaFilled(false);
    }
    
    @Override
    public void paintComponent(Graphics g) {
        Graphics2D g2 = (Graphics2D) g;
        
        if (getModel().isPressed()) {
            g.setColor(ColorProperties.BUTTON_BACKGROUND);
            g2.fillRect(3, 3, getWidth() - 6, getHeight() - 6);
        }
        super.paintComponent(g);

        if (mouseIn) {
            g2.setColor(ColorProperties.BUTTON_EDGE);
        } else {
            g2.setColor(ColorProperties.BUTTON_EDGE_HOVER);
        }
        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        g2.setStroke(new BasicStroke(1.2f));
        g2.draw(new RoundRectangle2D.Double(1, 1, (getWidth() - 3),
                (getHeight() - 3), 12, 8));
        g2.setStroke(new BasicStroke(1.5f));
        g2.drawLine(4, getHeight() - 3, getWidth() - 4, getHeight() - 3);
        
        g2.dispose();
    }
    
    @Override
    public void mouseClicked(MouseEvent e) {
    }

    @Override
    public void mouseEntered(MouseEvent e) {
        mouseIn = true;
    }

    @Override
    public void mouseExited(MouseEvent e) {
        mouseIn = false;
    }

    @Override
    public void mousePressed(MouseEvent e) {
    }

    @Override
    public void mouseReleased(MouseEvent e) {
    }
}
